var app = getApp();

Page({
    data: {
        mails: [],
        is_show: !0,
        _is_load: !0,
        mailss: []
    },
    onLoad: function(a) {
        var t = this, i = a.cid;
        t.setData({
            mails_id: i
        }), app.globalData.hasLogin ? t.setData({
            userInfo: app.globalData.userInfo
        }) : app.util.getUserInfo(function(a) {
            app.globalData.hasLogin = !0, t.setData({
                userInfo: a
            }), (app.globalData.userInfo = a).memberInfo || t.setData({
                fail: !0
            });
        });
    },
    onReady: function() {},
    onShow: function() {
        var t = this;
        app.util.request({
            url: "entry/wxapp/GetMailsa",
            data: {
                m: "bbyscm_card",
                m_id: t.data.mails_id
            },
            success: function(a) {
                0 == a.data.errno && t.setData({
                    mails: a.data.data,
                    m_id: a.data.data.id,
                    m_name: a.data.data.mail_name,
                    m_cardid: a.data.data.admin_cardid,
                    m_openid: a.data.data.admin_openid,
                    _is_load: !1
                });
            }
        }), app.util.request({
            url: "entry/wxapp/GetCard",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                0 == a.data.errno && 0 == a.data.data && wx.showModal({
                    title: "你还没有创建名片，无法加入分会",
                    content: "你还没有创建名片，无法加入分会",
                    showCancel: !1,
                    success: function() {
                        wx.navigateTo({
                            url: "../edit/card-edit"
                        });
                    }
                }), t.setData({
                    my_info: a.data.data,
                    my_cardid: a.data.data.id,
                    my_name: a.data.data.cardname
                });
            }
        }), app.util.request({
            url: "entry/wxapp/GetMailsss",
            data: {
                m: "bbyscm_card",
                ms_id: t.data.mails_id
            },
            success: function(a) {
                0 == a.data.errno && (0 == a.data.data.mail_key ? wx.showModal({
                    title: "提示",
                    content: "你的申请已提交管理员审核！请耐心等待！",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateTo({
                            url: "/pages/card/index/index"
                        });
                    }
                }) : 1 == a.data.data.mail_key ? wx.navigateTo({
                    url: "/pages/card/mail/mail?mid=" + t.data.mails_id
                }) : 2 == a.data.data.mail_key && wx.showModal({
                    title: "提示",
                    content: "很遗憾！管理员拒绝你的申请！你可以去创建自己的分会！",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateTo({
                            url: "/pages/card/mails/mail_list"
                        });
                    }
                }), t.setData({
                    mailss: a.data.data,
                    mail_key: a.data.data.mail_key
                }));
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    add_mailss: function(a) {
        var t = this;
        t.setData({
            btn_disabled: !0,
            submitIsLoading: !0
        }), JSON.stringify(a.detail.value);
        var i = t.data.m_id, n = a.detail.formId, e = t.data.m_name, d = t.data.m_cardid, s = t.data.m_openid, o = t.data.my_cardid, c = t.data.my_name;
        return e ? o ? (wx.showToast({
            title: "提交中...",
            icon: "loading",
            duration: 2e3
        }), void app.util.request({
            url: "entry/wxapp/PostMyMailss",
            data: {
                m: "bbyscm_card",
                mail_id: i,
                admin_cardid: d,
                admin_openid: s,
                mail_member: o,
                my_name: c,
                m_name: e,
                page: "pages/card/mail/mail?mid=" + t.data.mails_id,
                form_id: n,
                formIdkey: 0,
                mail_key: 0
            },
            success: function(a) {
                0 == a.data.errno ? wx.showModal({
                    title: "提示",
                    content: "提交成功！请等待管理员审核",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateTo({
                            url: "/pages/card/index/index"
                        });
                    }
                }) : wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            fail: function(a) {
                wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            complete: function() {
                wx.hideToast();
            }
        })) : (wx.showModal({
            title: "提示",
            content: "没有你的名片信息",
            showCancel: !1,
            success: function(a) {
                a.confirm;
            }
        }), !1) : (wx.showModal({
            title: "提示",
            content: "请填写分会名称",
            showCancel: !1,
            success: function(a) {
                a.confirm;
            }
        }), !1);
    },
    look_card_info_bind: function(a) {
        wx.navigateTo({
            url: "../mail/mail?mid=" + a.currentTarget.id
        });
    },
    signout_mails: function(a) {
        wx.navigateTo({
            url: "/pages/card/index/index"
        });
    },
    onNavigateTap: function(a) {
        this.setData({
            fail: !1
        });
    }
});